<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="net.sf.json.JSONObject"%>
<%@page import="com.sinodata.bsm.center.util.spring.SpringContextHolder"%>
<%@page import="com.sinodata.bsm.center.service.config.PortalService"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.sinodata.bsm.center.user.UserUtil"%>
<%@page import="com.sinodata.bsm.center.purview.UserFunctionValidate"%>
<%@page import="com.sinodata.bsm.center.purview.FunctionConstants"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%
String param = request.getParameter("args");
JSONObject parameter = "".equals(param) ? null : JSONObject.fromObject(param);
Integer time = null;
if(parameter == null){
    time = 0;
}else{
    time = Integer.valueOf(parameter.getString("PARAM_time"));
}
StringBuffer sql = new StringBuffer();
sql.append("select sum(case when  notify_mode = 1 then 1 else 0 end) as mode1,");
sql.append("sum(case when  notify_mode = 2 then 1 else 0 end) as mode2");
sql.append(" from notify_his where 1=1 ");
String format = "yyyyMMdd";
SimpleDateFormat simple = new SimpleDateFormat(format);
if(time == 1){//今天
    sql.append("and time").append(" > to_date('" + simple.format(new Date()) + "','yyyy-MM-dd hh24:mi')");
}else if(time == 2){//本周
    Calendar calendar = Calendar.getInstance(Locale.CHINA);
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    sql.append("and time").append(" > to_date('" + simple.format(calendar.getTime()) + "','yyyy-MM-dd hh24:mi')");
}else if(time == 3){//本月
    Calendar calendar1 = Calendar.getInstance(Locale.CHINA);
    calendar1.add(Calendar.MONTH, -1);
    sql.append("and time").append(" > to_date('" + simple.format(calendar1.getTime()).substring(0, 6) + "01','yyyy-MM-dd hh24:mi')");
}
PortalService service = SpringContextHolder.getBean(PortalService.class);

  //System.out.println(sql.toString());
List<Map<String,Object>> list = service.findListBySql(sql.toString());

%>
<div style="height:100px; background:#fafafa; overflow:hidden;" align="center">
<div style="width:100px; float:left;background:#fafafa;overflow:hidden;margin:0px 2px 3px 8px;">
	<ul  class="xUl">
		<li><span><img src="../../style/default/bsm/images/mail.png" /></span></li>
		<li>
			<span>邮件(
			<%if(list != null && list.get(0).get("MODE2") != null){%>
			    <a href='../../event/notify-his!common.action?flag=1&mode=2&time=<%=time%>' target='_blank'><%=list.get(0).get("MODE2") %></a>
			<%}else{%>
			  	<a href='../../event/notify-his!common.action?flag=1&mode=2&time=<%=time%>' target='_blank'>0</a>
			<%}%>
			)</span>
		</li>
	</ul>

</div>
<div style="width:100px; float:left;background:#fafafa;overflow:hidden;margin:0px 2px 3px 8px;">
	<ul  class="xUl">
		<li><span><img src="../../style/default/bsm/images/sms.png" /></span></li>
		<li>
			<span>短信(
			     <% if(list!= null && list.get(0).get("MODE1") != null){%>
			         <a href='../../event/notify-his!common.action?flag=1&mode=1&time=<%=time%>' target='_blank'><%=list.get(0).get("MODE1") %></a>
			     <%}else{%>
			      	<a href='../../event/notify-his!common.action?flag=1&mode=1&time=<%=time%>' target='_blank'>0</a>
			     <%}%>
			)</span>
		</li>
	</ul>

</div>
</div>

